<?php 
$username = 'root';
$password = '';
try {
$db = new PDO("mysql:dbname=osjetizg",$username, $password);
  $db->setAttribute(PDO::ATTR_ERRMODE,
                    PDO::ERRMODE_EXCEPTION);
  $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,
                    PDO::FETCH_NAMED);
  $db->exec("SET NAMES utf8");
} catch (PDOException $e) {
  header('Content-Type: text/plain');
  die("Problem s bazom: $e");
}

/*** pripremanje upita:
$q = $db->prepare("SELECT * FROM tbl WHERE id=?");
$q->execute(array($id));
*/
/*** dohvacanje po redovima:
foreach ($q as $redak) {
}
*/
/*** dohvacanje cijelog skupa rezultata:
$sve = $q->fetchAll();
*/

?>